﻿
@{
    ViewBag.Title = "RoleEdit";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
    var role = ViewBag.RoleInfo as LuDragon.Data.Entities.Sys_Role;
}


<span class="layui-breadcrumb">
    <a>系统设置</a>
    <a>角色管理</a>
    <a><cite>编辑</cite></a>
</span>
<hr />
<form class="layui-form" method="post" action="SaveRole" id="form1">
    <table class="layui-table layui-table-add layui-table-detail" lay-skin="nob">
        <tbody>
            <tr>
                <th><span class="red">*</span>角色名称</th>
                <td>
                    <div class="width">
                        <input type="text" name="RoleName" placeholder="请输入角色名称" autocomplete="off" class="layui-input" value="@(role?.RoleName)">
                    </div>
                </td>
            </tr>
            <tr>
                <th><span class="red"></span>是否系统角色</th>
                <td>
                    <div class="width">
                        <input type="checkbox" checked="@(role?.IsSystem)" lay-skin="switch" lay-text="是|否" id="check">
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
    <div class="layui-button">
        <button class="layui-btn" id="save">保存</button>
        <button type="reset" class="layui-btn layui-btn-primary" onclick="javascript: history.back();">返回上一页</button>
    </div>
    <input type="hidden" name="RoleId" value="@(role?.RoleId)" />
    <input type="hidden" name="IsSystem" value="@(role?.IsSystem)" id="IsSystem" />
    <input type="hidden" name="NavIds" value="@(role?.NavIds)" />
</form>


<script>
    //保存
    $("#save").click(function () {
        $("#IsSystem").val($("#check").is(":checked") ? true : false);
        $("#form1").ajaxForm(function (result) {
            var data = JSON.parse(result);
            if (data.Code == 200) {
                dialog.prompt("保存成功");
                location.href = "RoleList";
            } else {
                dialog.prompt("操作失败，请稍后重试");
            }
        });
    });
</script>